const Base = require('../../base.js');

module.exports = class extends Base {
  async indexAction() {
    let userInfo = await this.session('user_info')
    if (!userInfo) return this.fail(-1, '未登录授权')
    let dealList = await this.model('deal/index').all(userInfo._id)
    let money = 0
    dealList.forEach(item => {
      if (item.type == 'deduct') {
        money += item.money
      }
    })
    this.json({
      status: 200, message: 'success', data: money
    })
  }
};
